﻿using System;
using System.Collections.Generic;
using System.Data;

namespace BLL.SUBSYSTEM
{
  /// <summary>
	/// 业务逻辑类SUBSYS_LOGIN 的摘要说明。
	/// </summary>
	public class SUBSYS_LOGIN
	{
		private readonly OracleDAL.SUBSYSTEM.SUBSYS_LOGIN OracleDAL=new OracleDAL.SUBSYSTEM.SUBSYS_LOGIN();
        /// <summary>
        /// 
        /// </summary>
		public SUBSYS_LOGIN()
		{}
		#region  成员方法
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string SUBSYSTEMID,string USERISN)
		{
			return OracleDAL.Exists(SUBSYSTEMID,USERISN);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Model.SUBSYSTEM.SUBSYS_LOGIN model)
		{
			OracleDAL.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public void Update(Model.SUBSYSTEM.SUBSYS_LOGIN model)
		{
			OracleDAL.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public void Delete(string SUBSYSTEMID,string USERISN)
		{
			
			OracleDAL.Delete(SUBSYSTEMID,USERISN);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.SUBSYSTEM.SUBSYS_LOGIN GetModel(string SUBSYSTEMID,string USERISN)
		{
			
			return OracleDAL.GetModel(SUBSYSTEMID,USERISN);
		}

        ///// <summary>
        ///// 得到一个对象实体，从缓存中。
        ///// </summary>
        //public Model.SUBSYSTEM.SUBSYS_LOGIN GetModelByCache(string SUBSYSTEMID,string USERISN)
        //{
			
        //    string CacheKey = "SUBSYS_LOGINModel-" + SUBSYSTEMID+USERISN;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = OracleDAL.GetModel(SUBSYSTEMID,USERISN);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (Model.SUBSYSTEM.SUBSYS_LOGIN)objModel;
        //}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return OracleDAL.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SUBSYSTEM.SUBSYS_LOGIN> GetModelList(string strWhere)
		{
			DataSet ds = OracleDAL.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SUBSYSTEM.SUBSYS_LOGIN> DataTableToList(DataTable dt)
		{
			List<Model.SUBSYSTEM.SUBSYS_LOGIN> modelList = new List<Model.SUBSYSTEM.SUBSYS_LOGIN>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.SUBSYSTEM.SUBSYS_LOGIN model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.SUBSYSTEM.SUBSYS_LOGIN();
					model.SUBSYSTEMID=dt.Rows[n]["SUBSYSTEMID"].ToString();
					model.USERISN=dt.Rows[n]["USERISN"].ToString();
					model.USERNAME=dt.Rows[n]["USERNAME"].ToString();
                    model.USERPWD = dt.Rows[n]["USERPWD"].ToString();
					model.REMARK=dt.Rows[n]["REMARK"].ToString();
					if(dt.Rows[n]["CREATETIME"].ToString()!="")
					{
						model.CREATETIME=DateTime.Parse(dt.Rows[n]["CREATETIME"].ToString());
					}
					if(dt.Rows[n]["MODIFYTIME"].ToString()!="")
					{
						model.MODIFYTIME=DateTime.Parse(dt.Rows[n]["MODIFYTIME"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return OracleDAL.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  成员方法
	}
}

